package com.aatattoo.light_food_service.service;

import com.aatattoo.light_food_service.entity.Comment;
import com.aatattoo.light_food_service.mapper.CommentMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author aatattoo
 * @Date 2021/12/13 12:02 下午
 * @msg:
 */
@Service
@Component
public class CommentService {
    @Autowired
    CommentMapper commentMapper;

    /**
     * 添加评论
     * @param comment
     * @return 返回添加的评论id
     */
    public int addComment(Comment comment){
        commentMapper.addComment(comment);
        return comment.getId();
    }

    public int updataHaveReply(Comment comment){
        return commentMapper.updataHaveReply(comment);
    }

    public int deleteById(int id){
        return commentMapper.deleteById(id);
    }

    public List<Comment> findByDynamicId(int dynamicId){
        return commentMapper.findByDynamicId(dynamicId);
    }

    public int countRemind(Comment comment){
        return commentMapper.countRemind(comment);
    }

    public     int countComment(int dynamicId){
        return commentMapper.countComment(dynamicId);
    }

   public List<Integer> findByDynamicIdForId(int dynamicId){
        return commentMapper.findByDynamicIdForId(dynamicId);
   }

    public int updataRemind(int commentId){
        return commentMapper.updataRemind(commentId);
    }

    public List<Comment> findByUserId(int userId){
        return commentMapper.findByUserId(userId);
    }

    public Comment findByCommentId(int commentId){
        return commentMapper.findByCommentId(commentId);
    }

    public int deleteByDynamicId(int dynamicId){
        return commentMapper.deleteByDynamicId(dynamicId);
    }
}
